/*
* 高德地图初始化
* */
const { mapStyleId, cityName, center, zoom } = global.dataConfig

/**
* 设置城市
* @params ${cityName}
* @params ${callback}
* */
export function setAmpCity (map, cityName, callback) {
  map.setCity(cityName, (data) => {
    callback(data)
  })
}

/**
* 设置标记
* @params ${position}
* @params ${icon}
* */
export function setAmpPoint (map, { position, image }) {
  new AMap.Marker({
    map: map,
    position: position,
    icon: new AMap.icon({
      size: new AMap.Size(40, 50),
      image: image,
      imageOffset: new AMap.Pixel(0, -60)
    })
  })
}

/**
* @params ${dom}
* @params ${callback}
* */
export function initAmap (dom, callback) {
  const map = new AMap.Map(dom, {
    mapStyle: `amap://styles/${mapStyleId}`,
    center: center,
    zoom: zoom,
    resizeEnable: true,
    animateEnable: true,
    isHotspot: true
  })
  // 回调map
  callback(map)
}

